<template>
  <div>
    <el-dialog :visible="isShow" title="题目审核" width="400px" @close="btnCell">
      <el-row>
        <el-radio v-model="chkStates" label="1">通过</el-radio>
        <el-radio v-model="chkStates" label="2">拒绝</el-radio>
      </el-row>
     <el-row style="margin-top:30px">
          <el-input
        type="textarea"
        placeholder="请输入审核意见"
        v-model="chkRemarks"
         clearable
         :row="20"
        >
      </el-input>
        <div style="float:right; margin-top:30px">
           <el-button @click="btnCell">取消</el-button>
           <el-button type="primary" @click="btnOk">确定</el-button>
        </div>
     </el-row>
    </el-dialog>
  </div>
</template>
<script>
import { choiceCheck } from '@/api/hmmm/questions'// 审核试题
export default {
  data () {
    return {
      chkRemarks: '', // 审核意见
      chkStates: '1' // 审核状态
    }
  },
  props: {
    isShow: {
      type: Boolean,
      required: true
    },
    auditId: {
      type: Number,
      // eslint-disable-next-line vue/require-valid-default-prop
      default: false
    },
    getchoiceness: {
      type: Array,
      required: true
    }

  },
  methods: {
    // 审核状态
    chkState (data) {
      if (data === 0) {
        return '待审核'
      } else if (data === 1) {
        return '已审核'
      } else {
        return '已拒绝'
      }
    },
    // 取消按钮
    btnCell () {
      this.$emit('update:isShow', false)
    },
    // 确定按钮
    async btnOk () {
      // auditOpinions({id:this.auditId,chkState:this.chkState,chkRemarks:this.chkRemarks}).then(() => {
      // const index =  this.getchoiceness.findIndex(item => item.id === this.auditId)
      // this.getchoiceness[index]['chkRemarks'] = this.chkRemarks
      // this.getchoiceness[index]['chkState'] = this.chkState
      // })
      // this.$emit('update:isShow', false)
      if (this.chkRemarks === '' || this.chkStates === '') {
        return this.$message.warning('请输入审核意见')
      }
      try {
        this.$emit('update:isShow', false)
        const obj = {
          id: this.auditId,
          chkState: this.chkStates * 1,
          chkRemarks: this.chkRemarks
        }
        await choiceCheck(obj)
        this.$message.success('操作成功')
        this.disabled = true
        // 重新加载
        this.$emit('setAudit')
      } catch (err) {
        console.log(err)
      }
    }
  }
}
</script>

<style>
</style>
